// Copyright (c) Microsoft Corporation. All rights reserved.

#include <windows.h>
#include <tchar.h>

#define COUNT_OF(x)  (sizeof(x)/sizeof(x[0]))

// The purpose of this program is to hang around until an environment variable is set from a remote process

int _cdecl _tmain()
{
	TCHAR pBuf[256];

	_tprintf(_T("Waiting for CR_UTILITY_REMOTE_TEST to be set to 'stop' ..."));

	while (true)
	{
		DWORD dw = ::GetEnvironmentVariable(_T("CR_UTILITY_REMOTE_TEST"), pBuf, COUNT_OF(pBuf));

		if (dw > 0)
		{
			if (_tcsicmp(pBuf, _T("stop")) == 0)
			{
				return 0;	
			}
		}
		
		Sleep(100);
	}
	
	return 255;
}
